package cn.simon.rabbitmq;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @功能描述： 消费者
 * @Auther: simon-yi'an
 */
@Service
@Slf4j
public class MQreceive {

    @RabbitListener(queues = "queue")
    public void receive(Object obj){
        log.info("接收到的消息："+obj);
    }
    /**
     * @功能描述:广播模式队列
     * @Param:
     * @Return:
     * @Author simon-yi'an
     * @Date 2022/11/6 22:39
     */
    @RabbitListener(queues = "queue_fanout01")
    public void receive01(Object obj){
        log.info("queue_fanout01队列接收广播："+obj);
    }
    /**
     * @功能描述: 广播模式队列
     * @Param:
     * @Return:
     * @Author simon-yi'an
     * @Date 2022/11/6 22:39
     */
    @RabbitListener(queues = "queue_fanout02")
    public void receive02(Object obj){
        log.info("queue_fanout02队列接受广播："+obj);
    }
    /**
     * @功能描述: 直接模式队列
     * @Param:
     * @Return:
     * @Author simon-yi'an
     * @Date 2022/11/6 22:41
     */
    @RabbitListener(queues = "queue_direct01")
    public void receive03(Object obj){
        log.info("queue_direct01接收到消息："+obj);
    }
    /**
     * @功能描述: 直接模式队列
     * @Param:
     * @Return:
     * @Author simon-yi'an
     * @Date 2022/11/6 22:42
     */
    @RabbitListener(queues = "queue_direct02")
    public void receive04(Object obj){
        log.info("queue_direct02接收到消息："+obj);
    }

    /**
     * @功能描述: 主题模式
     * @Param:
     * @Return:
     * @Author simon-yi'an
     * @Date 2022/11/6 22:42
     */
    @RabbitListener(queues = "queue_topic01")
    public void receive05(Object obj){
        log.info("queue_topic01接收到消息："+obj);
    }
    /**
     * @功能描述: 主题模式
     * @Param:
     * @Return:
     * @Author simon-yi'an
     * @Date 2022/11/6 22:47
     */
    @RabbitListener(queues = "queue_topic02")
    public void receive06(Object obj){
        log.info("queue_topic02接收到消息："+obj);
    }
    /**
     * @功能描述: 头部信息
     * @Param:
     * @Return:
     * @Author simon-yi'an
     * @Date 2022/11/7 0:47
     */
    @RabbitListener(queues = "queue_header01")
    public void receive07(Message message){
        log.info("queue_header01队列信息地址："+message);
        log.info("queue_header01接收到的消息："+new String(message.getBody()) );
    }
    /**
     * @功能描述: 头部信息
     * @Param:
     * @Return:
     * @Author simon-yi'an
     * @Date 2022/11/7 0:47
     */
    @RabbitListener(queues = "queue_header02")
    public void receive08(Message message){
        log.info("queue_header02队列信息地址："+message);
        log.info("queue_header02接收到的消息："+new String(message.getBody()) );
    }
}
